<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"  @submit.native.prevent @keyup.enter.native="handleQuery">
      <el-form-item label="申请人" prop="qKey">
        <el-input v-model="queryParams.qKey" placeholder="姓名" clearable></el-input>
      </el-form-item>
      <el-form-item label="部门" prop="qIds1">
        <el-cascader
          v-model="queryParams.qIds1"
          :options="deptList"
          :props="{value: 'id',children: 'children',label: 'label',expandTrigger:'hover'}"
          filterable
          clearable
          placeholder=""
          style="width: 400px;"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="季度" prop="qTimeStart">
        <el-date-picker
          v-model="queryParams.qTimeStart"
          type="month"
          placeholder=""
          value-format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table ref="tables" v-loading="loading" :data="dataList" @sort-change="handleSortChange">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="姓名" align="center" prop="nickName" fixed/>
      <el-table-column label="部门" align="center" prop="deptName" width="200"/>
      <el-table-column label="总积分" align="center" prop="score" sortable="custom"/>
      <el-table-column label="基础类" align="center" prop="score10" sortable="custom"/>
      <el-table-column label="扣减类" align="center" prop="score20" sortable="custom"/>
      <el-table-column label="活动参与类" align="center" prop="score30" sortable="custom"/>
      <el-table-column label="学习提升类" align="center" prop="score40" sortable="custom"/>
      <el-table-column label="社会服务类" align="center" prop="score50" sortable="custom"/>
      <el-table-column label="党建工作类" align="center" prop="score60" sortable="custom"/>

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>

export default {
  name : "Forms",
  dicts: ['apply_status','pass'],
  data() {
    return {
      deptList:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        qKey: "",
        qIds1: undefined,
        qTimeStart: new Date(),
        qStatus: undefined,
        pageNum: 1,
        pageSize: 10,
        isAsc:undefined,
        orderByColumn:undefined
      },
      dialogTableVisible:false,

    };
  },
  created() {
    //this.getList();
    this.getDepts();
  },
  activated() {
    this.getList();
  },
  methods: {
    getDepts(){
      this.request({
        url: '/system/user/deptTree',
        method: 'get',
      }).then(response => {
        this.deptList = response.data;
      });
    },
    getList() {
      this.loading = true;
      this.request({
        url: '/forms/forms/list',
        method: 'get',
        params: this.queryParams
      }).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.isAsc = undefined;
      this.queryParams.orderByColumn = undefined;
      this.queryParams.pageNum = 1;
      this.$refs.tables.clearSort();
      this.getList();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 排序触发事件 */
    handleSortChange(column, prop, order) {
      this.queryParams.orderByColumn = this.getLowLineCase(column.prop);
      this.queryParams.isAsc = column.order;
      this.getList();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },

  }
};
</script>

